/*
 * BasicPlayerEvent.
 * 
 * JavaZOOM : jlgui@javazoom.net
 *            http://www.javazoom.net
 *
 *-----------------------------------------------------------------------
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as published
 *   by the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Library General Public License for more details.
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *----------------------------------------------------------------------
 */
package pl.vanta.mjuzik2.impl.player.engine;

import pl.vanta.mjuzik2.impl.player.PlayerEvent;

/**
 * This class implements player events.
 */
public class BasicPlayerEvent
{
	private PlayerEvent	event		= PlayerEvent.UNKNOWN;
	private int			position	= -1;
	private double		value		= -1.0;
	private Object		source		= null;
	private Object		description	= null;

	/**
	 * Constructor
	 * 
	 * @param source
	 *            of the event
	 * @param code
	 *            of the envent
	 * @param position
	 *            optional stream position
	 * @param value
	 *            opitional control value
	 * @param desc
	 *            optional description
	 */
	public BasicPlayerEvent(Object source, PlayerEvent event, int position, double value, Object desc)
	{
		this.value = value;
		this.position = position;
		this.source = source;
		this.event = event;
		this.description = desc;
	}

	/**
	 * Return code of the event triggered.
	 * 
	 * @return
	 */
	public PlayerEvent getEvent()
	{
		return this.event;
	}

	/**
	 * Return position in the stream when event occured.
	 * 
	 * @return
	 */
	public int getPosition()
	{
		return this.position;
	}

	/**
	 * Return value related to event triggered.
	 * 
	 * @return
	 */
	public double getValue()
	{
		return this.value;
	}

	/**
	 * Return description.
	 * 
	 * @return
	 */
	public Object getDescription()
	{
		return this.description;
	}

	public Object getSource()
	{
		return this.source;
	}

	public String toString()
	{
		if (this.event == PlayerEvent.OPENED)
			return "OPENED:" + this.position;
		else if (this.event == PlayerEvent.OPENING)
			return "OPENING:" + this.position + ":" + this.description;
		else if (this.event == PlayerEvent.PLAYING)
			return "PLAYING:" + this.position;
		else if (this.event == PlayerEvent.STOPPED)
			return "STOPPED:" + this.position;
		else if (this.event == PlayerEvent.PAUSED)
			return "PAUSED:" + this.position;
		else if (this.event == PlayerEvent.RESUMED)
			return "RESUMED:" + this.position;
		else if (this.event == PlayerEvent.SEEKING)
			return "SEEKING:" + this.position;
		else if (this.event == PlayerEvent.SEEKED)
			return "SEEKED:" + this.position;
		else if (this.event == PlayerEvent.EOM)
			return "EOM:" + this.position;
		else if (this.event == PlayerEvent.PAN)
			return "PAN:" + this.value;
		else if (this.event == PlayerEvent.GAIN)
			return "GAIN:" + this.value;
		else
			return "UNKNOWN:" + this.position;
	}
}